<template>
  <div>
    <mini-head :title="$route.name"/>
    <div class="wrap">
    <div class="denglu">
        <p>Hi,欢迎来到德莱联盟</p>
        <van-button
          round
          v-show="showLoginButton"
          @click="$router.push('/login')"
          >登陆/注册</van-button
        >
        <div class="name" v-show="!showLoginButton">
          <span class="name-"> {{ name }}</span>
          <br />
          <van-button round @click="exitLogin">退出登陆</van-button>
        </div>
      </div>
      <div class="order">
        <div class="order-nav">
          <p>我的订单</p>
          <p>
            <span>全部订单</span>
            <van-icon name="arrow" />
          </p>
        </div>
        <div class="order-container">
          <div>
            <van-icon name="refund-o"/>
            <p>待付款</p>
          </div>
          <div>
            <van-icon name="logistics"/>
            <p>今日配送</p>
          </div>
          <div>
            <van-icon name="records"/>
            <p>评价有礼</p>
          </div>
        </div>
      </div>
      <div class="card">
        <div>
          <van-icon name="vip-card-o"/>
          <p>优惠券</p>
        </div>
        <div>
          <van-icon name="medal-o"/>
          <p>权益卡</p>
        </div>
        <div>
          <van-icon name="paid"/>
          <p>余额</p>
        </div>
        <div>
          <van-icon name="location-o"/>
          <p>收货地址</p>
        </div>
      </div>
      <div class="card">
        <div>
          <van-icon name="phone-o"/>
          <p>联系客服</p>
        </div>
        <div>
          <van-icon name="smile-o"/>
          <p>帮助中心</p>
        </div>
        <div>
          <van-icon name="friends-o"/>
          <p>关于我们</p>
        </div>
        <div>
          <van-icon name="setting-o"/>
          <p>设置</p>
        </div>
      </div>
    </div>
   <tabbar/>
  </div>
</template>

<script>
import MiniHead from '../../components/MiniHead.vue'
import Tabbar from '../../components/Tabbar.vue'
import { Dialog } from 'vant'
import { gettoken } from '../../utils/index'
export default {
  components: { MiniHead, Tabbar },
  name: 'User',
  data () {
    return {
      name: '',
      showLoginButton: false

    }
  },
  created () {
    this.wt()
  },
  methods: {
    // 退出登陆
    exitLogin () {
      Dialog.confirm({
        title: '提示',
        message: '您是否确认退出'
      }).then(() => {
        localStorage.removeItem('token')
        localStorage.removeItem('vuex')
        this.showLoginButton = true
        this.$router.go(0)
      })
    },
    // 判断登录状态
    wt () {
      if (gettoken()) {
        this.name = localStorage.getItem('name')
        this.showLoginButton = false
      } else {
        this.showLoginButton = true
      }
    }
  }

}
</script>

<style lang="scss" scoped>
  .denglu {
    position: absolute;
    top: 0rem;
    left: 0;
    width: 100%;
    height: 5.8125rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    .name {
      font-size: 0.5rem;
      color: rgba(122, 78, 243, 0.5);
      text-align: center;
      .name- {
        display: inline-block;
        margin: 0 auto 0.2rem;
      }
    }
    p {
      font-size: 0.5rem;
      margin: 0.375rem auto;
      color: rgb(74, 83, 67);
    }
  }
.wrap{
  padding-top: 46px;
  padding-bottom: 50px;
  color: #444;
  .user{
    border-bottom: 1px solid #f1f1f1;
    background-color: #f1f1f1;
    width: 100%;
    height: 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0.5rem 0;
    p{
      font-size: 16px;
      color: #444;
    }
    .login{
      height: 0.9rem;
      padding: 0 24px;
    }
  }
  .order{
    margin-top: 80px;
    width: 100%;
    .order-nav{
      display: flex;
      justify-content: space-between;
      font-size: 16px;
      padding: 0 10px;
      border-bottom: 1px solid #f1f1f1;
    }
    .order-container{
      width: 100%;
      height: 100px;
      display: flex;
      justify-content: space-around;
      border-bottom: 1px solid #f1f1f1;
      div{
        width: 30%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        .icon{
          font-size: 36px;
        }
        p{
          font-size: 14px;
          margin-top: 5px;
        }
      }
    }
  }
  .card{
      width: 100%;
      height: 100px;
      display: flex;
      justify-content: space-around;
      border-bottom: 1px solid #f1f1f1;
      div{
        width: 25%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        .icon{
          font-size: 26px;
        }
        p{
          font-size: 14px;
          margin-top: 5px;
        }
      }
    }
}
</style>
